<?php
	namespace Home\Controller;
	use Think\Controller;

	class LoginController extends Controller
	{
		public function index()
		{
			$this->display('index');
		}

   		//销毁session
   		// public function logout()
   		// {
   		// 	unset($_SESSION['user']);
     //    	$this->redirect("Login/index");
   		// }


   		public function doLogin()
   		{
   			session_start();
   			$name = $_POST['name'];
   			$pass = md5($_POST['pass']);
   			$user = M('user')->where("name='{$name}'")->find();
   			$_SESSION['home']['id'] = $user['id'];
   			if($user){
				if($pass==$user['pass']){
					session("user",$user);
					$this->redirect("Index/index");
				}else{
					$this->assign('erroren','登录密码错误！');
					$this->display('index');
				}
			}else{
				$this->assign('erroren','登录账号错误！');
				$this->display('index');
			}

   		}
	} 